package com.example.base.app;

import com.example.base.utils.Result;
import com.example.base.utils.SpringContextUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class AppCallServiceImpl implements AppCallService{

    @Override
    public Object execute(String appName, String functionName, Map<String, Object> map) {
        try {
            AppFunctionMap appFunctionMap= SpringContextUtils.getBean(AppFunctionMap.class);
            Map<String,AppFunction> mapFunction=appFunctionMap.getAppFunctionMapByAppName(appName);
            AppFunction appFunction=mapFunction.get(functionName);
            return appFunction.appFunction(map);
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.errorInfo("暂时遇到问题,请稍后再试");
    }
}
